﻿
using System;
using System.Data;
using System.Collections.Generic;

namespace LDSP.BRL
{
    /// <summary>
    /// 系统管理员栏目权限
    /// </summary>
    public partial class R_SystemUserCatalog : BYFW.BOL.BaseEntity
    {
        public R_SystemUserCatalog()
        {
            m_tableName = "t_r_systemUser_catalog";
            m_tblCacheManager.IsEnable = true;
        }

        protected int m_systemUserID = 0;
        protected int m_catalogID = 0;
        protected SystemUser m_systemUser = null;
        protected Catalog m_catalog = null;

        /// <summary>
        /// 系统管理员ID
        /// </summary>
        public int SystemUserID
        {
            get { return m_systemUserID; }
            set { m_systemUserID = value; }
        }
        /// <summary>
        /// 栏目ID
        /// </summary>
        public int CatalogID
        {
            get { return m_catalogID; }
            set { m_catalogID = value; }
        }

        public SystemUser SystemUser
        {
            get
            {
                if (m_systemUser == null)
                {
                    m_systemUser = new SystemUser();
                    if (m_systemUserID != 0)
                    {
                        m_systemUser.GetProperties(m_systemUserID);
                    }
                }
                return m_systemUser;
            }
        }

        public Catalog Catalog
        {
            get
            {
                if (m_catalog == null)
                {
                    m_catalog = new Catalog();
                    if (m_catalogID != 0)
                    {
                        m_catalog.GetProperties(m_catalogID);
                    }
                }
                return m_catalog;
            }
        }

        protected override void FillContainer()
        {
            base.FillContainer();
            m_container.Add("systemUserID", m_systemUserID);
            m_container.Add("catalogID", m_catalogID);
        }

        public override bool GetProperties(System.Data.DataRow record)
        {
            if (!base.GetProperties(record))
            {
                return false;
            }
            m_systemUserID = this.GetIntValue(record, "systemUserID");
            m_catalogID = this.GetIntValue(record, "catalogID");
            return true;
        }

        public List<R_SystemUserCatalog> GetListBySystemUserID(int systemUserID)
        {
            return this.GetSpecialList<R_SystemUserCatalog>(null,"systemUserID",systemUserID);
        }

        public void DeleteBySystemUser(string transID, int systemUserID)
        {
            string cond = string.Format("where {0}={1}", DB.GetCol("systemUserID"), DB.GetVal(systemUserID));
            this.DeleteRecord(transID, cond);
        }

        public void DeleteByCatalog(string transID, int catalogID)
        {
            string cond = string.Format("where {0}={1}", DB.GetCol("catalogID"), DB.GetVal(catalogID));
            this.DeleteRecord(transID, cond);
        }
    }
}

